package com.sea.base.activities

import android.os.Bundle
import android.widget.FrameLayout
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding
import com.sea.base.R
import com.sea.base.ext.global.log
import com.sea.base.fragment.FragmentVisibilityChild
import com.sea.base.ui.switchFragment
import com.sea.base.utils.param.BundleParams

internal class EmbedActivity : BaseFullscreenKtActivity<ViewBinding>() {

    @BundleParams("fragClassName")
    private val fragClassName: String = ""

    @BundleParams("arguments")
    private val arguments: Bundle? = null

    override fun init(savedInstanceState: Bundle?) {
        val flRoot = FrameLayout(this)
        flRoot.id = R.id.fl_embed_activity_id
        setContentView(flRoot)
        try {
            val frag = Class.forName(fragClassName).newInstance() as Fragment
            frag as com.sea.base.fragment.FragmentVisibilityChild
            frag.arguments = arguments
            switchFragment(frag, flRoot.id)
        } catch (e: Exception) {
            e.message?.log("EmbedActivity")
        }
    }

    override fun bindData() {
    }
}